Skip to main content

All Questions

Tagged with
5votes
2answers
977views

Optimized data structure mapping finite set of integers to values in C++

I'm looking for a mapping data structure, but knowing that the possible values of my keys are small numbers, I would like to trade memory for better performances (for both random access and value ...
Delgan's user avatar
4votes
3answers
288views

Given two sparse vectors, compute their dot product

Problem Statement: Given two sparse vectors, compute their dot product. Implement class SparseVector: SparseVector(nums) Initializes the object with the vector nums dotProduct(vec) Compute the dot ...
Pankaj Kumar's user avatar
6votes
1answer
460views

Fastest function to `Remove Duplicate Lines` per each cell

The below function is used to Remove Duplicate Lines per each cell. It works without problem, but it is slow with a range of only one column and 17k rows. Actually, ...
Leedo's user avatar
1vote
2answers
72views

Shortest way possible to generate javascript string from a large array of values to A, B, C and n others

I have an array of values containing names, e.g. let members = [{id: 1, name: 'Tyler'}, {id: 2, name: 'John'}, {id: 3, name: 'Dayo'}, ..., {id: 7, name: 'George'] ...
Salman Malik's user avatar
1vote
1answer
164views

Minimum number of swaps to sort a array, but swaps only allowed with elements 2 apart

I wanted to solve a problem where I sort an array of any size and return the minimum number of swaps. The explanation for the distance 2 is that I choose 3 neighboring elements ABC and then swap them ...
programmerNoob1234's user avatar
4votes
1answer
186views

Langton's Ant cellular automaton in Java

I made a couple of little games and cellular automata in Java. For every new 'game', I used the same code as a base, except for the game logic of course. With every iteration of me customizing my ...
plankins's user avatar
5votes
2answers
329views

Porting PHP's array_push to Python

I am new to Python but not new to PHP. I've started porting PHP APIs to Python hoping to learn the Python language along the way, currently trying to grasp List, Dict, Set, Tuple. I tried writing PHP'...
hanshenrik's user avatar
1vote
1answer
765views

Proper way to transform nested lists to nested maps [closed]

I want to transform a list of lists of lists that I have in a MongoDB document into a map of maps of maps in my java Domain class. The problem I have is that the fields are mixed between the levels. ...
Paplusc's user avatar
2votes
1answer
91views

Sports DataSheet

This program asks the user for a players name, # of goals, saves, games played, etc. This information is ten organized on a .txt file along with the time the information was logged. users can also ...
Grewal_Creator's user avatar
5votes
1answer
832views

Find the shortest sub array that contains all element from 1 to K

I'm trying to solve this problem here. The question is all about finding the shortest sub array inside an array that contains all the element from 1 to K. Input: The first line contains three space-...
arctic_Oak's user avatar
7votes
2answers
815views

Number of occurrences of strings in array

This is a Hackerrank problem (https://www.hackerrank.com/challenges/sparse-arrays/problem). We're given an array of strings and an array of queries, and have to return an array of the number of ...
jeremy radcliff's user avatar
1vote
2answers
225views

Removing duplicate hashes in an array while keeping count of the times the hash was present

I have an array of hashes (price_params['items']) where each item has a key called quantity what I'm trying to do is to clean ...
Sebastian Delgado's user avatar
9votes
3answers
1kviews

Creating an affinity-matrix between protein and RNA sequences

I wrote an algorithm that analyzes protein-RNA interactions and I found that the following function is the bottleneck that causes performance issues: ...
KaPy3141's user avatar
3votes
0answers
2kviews

Alternative for VLOOKUP/Index-Match in VBA

I am sharing this function I wrote with the community to provide an alternative to slow VLOOKUP and/or Index-...
ARickman's user avatar
4votes
1answer
425views

LeetCode: Intersection of two arrays ii C#

https://leetcode.com/problems/intersection-of-two-arrays-ii/ Please review for performance, I am having a problem with using TryGetValue, if someone can explain how this can be used in here. Given ...
Gilad's user avatar
  • 5,293

153050per page
close